//
//  StoryTableViewCell.m
//  Travelling
//
//  Created by lanou on 15/12/16.
//  Copyright © 2015年 Morrrah. All rights reserved.
//

#import "StoryTableViewCell.h"
#import "Story.h"

@implementation StoryTableViewCell

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    AppDelegate *myDelegate = [UIApplication sharedApplication].delegate;
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _bgView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth / 1.78 * myDelegate.autoSizeScaleY)];
        
        _pictureView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth / 1.78 * myDelegate.autoSizeScaleY)];
        [_bgView addSubview:_pictureView];
        
        _shadowView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth / 1.78 * myDelegate.autoSizeScaleY)];
        _shadowView.backgroundColor = [UIColor blackColor];
        _shadowView.alpha = 0.4;

        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 60 * myDelegate.autoSizeScaleY, ScreenWidth, 30 * myDelegate.autoSizeScaleY)];
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont boldSystemFontOfSize:12.0 * myDelegate.autoSizeScaleY];
        [_shadowView addSubview:_titleLabel];
        
        _dateAndPlaceLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 80 * myDelegate.autoSizeScaleY, ScreenWidth, 25 * myDelegate.autoSizeScaleY)];
        _dateAndPlaceLabel.textColor = [UIColor whiteColor];
        _dateAndPlaceLabel.textAlignment = NSTextAlignmentCenter;
        _dateAndPlaceLabel.font = [UIFont systemFontOfSize:11.0 * myDelegate.autoSizeScaleY];
        [_shadowView addSubview:_dateAndPlaceLabel];
        
                [_bgView addSubview:_shadowView];
        [self.contentView addSubview:_bgView];
    }
    return self;
}


- (void)setStory:(Story *)story
{
    [_pictureView sd_setImageWithURL:[NSURL URLWithString:story.cover_image]];
    _titleLabel.text = story.name;
    _dateAndPlaceLabel.text = [NSString stringWithFormat:@"#%@/%@",story.popular_place_str,story.first_day];
}





@end
